<template>
  <div id="OrdersTitle">
    <v-details
      :inputConfig="inputConfig"
      :detailData="inputData"
      :rules="rules"
      ref="input"
    ></v-details>
  </div>
</template>

<script>
import details from '@/components/commons/Detail'
import baseMixin from "@/mixins/BaseMixin";

export default {
  props: {
    inputData: {
      type: Object,
    }
  },
  mixins: [baseMixin],
  name: "OrdersTitle",
  data () {
    return {
      addflag: false,
      strategytypeFlag: true,
      reqtypeFlag: true,
      sorttype1Flag: true,
      sorttype2Flag: true,
      sorttype3Flag: true,
      sorttype4Flag: true,
    }
  },
  computed: {
    inputConfig () {
      return [
        [
          {
            type: "input",
            label: this.$t('ex.strategycode'),
            props: "strategycode",
            disabled: this.addflag
          },

          {
            type: "select",
            label: this.$t('ex.strategytype'),
            props: "strategytype",
            options: this.getOptions("codelkup/RTXSTRATEGYTYPE"),
          },
          {
            type: "select",
            label: this.$t('ex.loctype',{no:1}),
            props: "loctype1",
            options: this.getOptions("codelkup/LOCCATEGRY"),
          },
          {
            type: "select",
            label: this.$t('ex.sorttype',{no:1}),
            props: "sorttype1",
            options: this.getOptions("codelkup/RTXSORTTYPE"),
          },
          {
            type: "select",
            label: this.$t('ex.sorttype',{no:3}),
            props: "sorttype3",
            options: this.getOptions("codelkup/RTXSORTTYPE"),
          },

        ],
        [
          {
            type: "input",
            label: this.$t('ex.descr'),
            props: "descr",
          },

          {
            type: "select",
            label: this.$t('ex.reqtype'),
            props: "reqtype",
            options: this.getOptions("codelkup/RTXREQTYPE"),
            disabled: this.strategytypeFlag
          },
          {
            type: "select",
            label: this.$t('ex.loctype',{no:2}),
            props: "loctype2",
            options: this.getOptions("codelkup/LOCCATEGRY"),
          },
          {
            type: "select",
            label: this.$t('ex.sortoption',{no:1}),
            props: "sortoption1",
            options: this.getOptions(`codelkup/ASCORDESC`),
            disabled: this.sorttype1Flag
          },
          {
            type: "select",
            label: this.$t('ex.sortoption',{no:3}),
            props: "sortoption3",
            options: this.getOptions(`codelkup/ASCORDESC`),
            disabled: this.sorttype3Flag
          },

        ],
        [
          {
            type: "select",
            label: this.$t('ex.cubesort'),
            props: "cubesort",
            options: this.getOptions("codelkup/RTXCUBESORT"),
          },


          {
            type: "select",
            label: this.$t('ex.pickarea'),
            props: "pickarea",
            options: this.getOptions("/queryAreadetailDropDown"),
            disabled: this.reqtypeFlag
          },
          {
            type: "select",
            label: this.$t('ex.loctype',{no:3}),
            props: "loctype3",
            options: this.getOptions("codelkup/LOCCATEGRY"),
          },
          {
            type: "select",
            label: this.$t('ex.sorttype',{no:2}),
            props: "sorttype2",
            options: this.getOptions("codelkup/RTXSORTTYPE"),

          },
          {
            type: "select",
            label: this.$t('ex.sorttype',{no:4}),
            props: "sorttype4",
            options: this.getOptions("codelkup/RTXSORTTYPE"),
          },
        ],
        [
          {
            type: "checkbox",
            label: this.$t('ex.wholeloc'),
            props: "wholeloc",
            disabled: this.strategytypeFlag
          },
          {
            type: "checkbox",
            label: this.$t('common.cancel'),
            props: "cancel",
          },

          {
            type: "select",
            label: this.$t('ex.loctype',{no:4}),
            props: "loctype4",
            options: this.getOptions("codelkup/LOCCATEGRY"),
          },
          {
            type: "select",
            label: this.$t('ex.sortoption',{no:2}),
            props: "sortoption2",
            options: this.getOptions(`codelkup/ASCORDESC`),
            disabled: this.sorttype2Flag
          },
          {
            type: "select",
            label: this.$t('ex.sortoption',{no:4}),
            props: "sortoption4",
            options: this.getOptions(`codelkup/ASCORDESC`),
            disabled: this.sorttype4Flag
          },
        ],
        [
          {
            type: "checkbox",
            label: this.$t('config.loseId'),
            props: "loseid",
          },
        ]
      ]
    },
    rules () {
      return {

      }
    }
  }
  ,
  methods: {
  },
  mounted () {
    if (Object.keys(this.$store.state.skip).length !== 0) {
      let data = this.$store.state.skip;
      if (data.newFlag) {
        this.addflag = false;
      } else {
        this.addflag = true;
      }
    } else if (this.$store.state.newFlag) {
      this.addflag = false;
    } else {
      this.addflag = true;
    }
  },
  watch: {
    "inputData.strategytype" (data) {
      //如果补货类型(strategytype)为波次补货,则禁止需求类型和零拣区域
      if (data === '2' || data == ' ') {
        this.strategytypeFlag = true;
        this.inputData.reqtype = ''
      } else {
        this.strategytypeFlag = false;
      }
    },
    "inputData.reqtype" (data) {
      //如果需求类型(reqtype)为零拣位补货,则可以选择零拣区域(pickarea)
      if (data === '2') {
        this.reqtypeFlag = false;
      } else {
        this.inputData.pickarea = ''
        this.reqtypeFlag = true;
      }
    },
    "inputData.sorttype1" (data) {
      if (data === '1' || data == '') {
        this.sorttype1Flag = true
        this.inputData.sortoption1 = ''
      } else {
        this.sorttype1Flag = false
      }
    },
    "inputData.sorttype2" (data) {
      if (data === '1' || data == '') {
        this.sorttype2Flag = true
        this.inputData.sortoption2 = ''
      } else {
        this.sorttype2Flag = false
      }
    },
    "inputData.sorttype3" (data) {
      if (data === '1' || data == '') {
        this.sorttype3Flag = true
        this.inputData.sortoption3 = ''
      } else {
        this.sorttype3Flag = false
      }
    },
    "inputData.sorttype4" (data) {
      if (data === '1' || data == '') {
        this.sorttype4Flag = true
        this.inputData.sortoption4 = ''
      } else {
        this.sorttype4Flag = false
      }
    },
  },
  components: {
    'v-details': details
  }
}
</script>

<style scoped>
</style>
